<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>消息通知</title>
    <script src="../../static/js/axios-0.18.0.js"></script>
    <script src="../../static/plugins/echarts/echarts.js"></script>
    <script src="../../static/js/vue.js"></script>
    <link href="https://cdn.bootcdn.net/ajax/libs/element-ui/2.15.1/theme-chalk/index.css" rel="stylesheet">
    <script src="https://cdn.bootcdn.net/ajax/libs/element-ui/2.15.1/index.js"></script>

    <style>
        .isred{
            color: red;
        }
        .isgreen{
            color: green;
        }
    </style>
</head>
<body class="hold-transition">
<div id="app">
    <div class="app-container">
        <div class="box">
            <div class="filter-container">
                <el-input @keyup.enter.native="findPage()" placeholder="商品名称" v-model="pagination.queryString" style="width: 200px;" class="filter-item"></el-input>
                <el-button @click="findPage()" class="dalfBut">查询</el-button>
                <template>
                    <h4 class="el-icon-help">选择状态</h4>
                    <el-select placeholder="全部商品" v-model="findstatus" @change="findPage()">
                        <el-option key="1" label="全部通知" value=""></el-option>
                        <el-option key="2" label="商品违规" value="商品违规"></el-option>
                        <el-option key="3" label="商品售出" value="商品售出"></el-option>
                        <el-option key="4" label="审核通过" value="审核通过"></el-option>
                        <el-option key="5" label="商品评论" value="账号封禁"></el-option>
                        <el-option key="6" label="商品收藏" value="账号解封"></el-option>
                    </el-select>
                </template>
            </div>
            <el-table size="small" current-row-key="id" :data="dataList" @row-click="rowclick" stripe highlight-current-row >
                <el-table-column type="index" align="center" label="序号" ></el-table-column>
                <el-table-column prop="isread" label="状态" align="center">
                    <template slot-scope="scope">
                        <span v-if="scope.row.isread === 0" class="isred"><i style="font-size: 20px" class="el-icon-chat-dot-round"></i></span>
                        <span v-else class="isgreen"><i style="font-size: 20px" class="el-icon-chat-dot-round"></i></span>
                    </template>
                </el-table-column>
                <el-table-column prop="tpname" label="类型" align="center"></el-table-column>
                <el-table-column prop="whys" label="内容" align="center"></el-table-column>
                <el-table-column prop="nttime" label="时间" align="center"></el-table-column>
            </el-table>
            <!--分页-->
            <div class="pagination-container">
                <el-pagination
                        class="pagiantion"
                        @current-change="handleCurrentChange"
                        :current-page="pagination.currentPage"
                        :page-size="pagination.pageSize"
                        layout="total, prev, pager, next, jumper"
                        :total="pagination.total">
                </el-pagination>
            </div>
        </div>
    </div>
</div>
</body>
<script>
    var vue = new Vue({
        el:'#app',
        data:{
            findstatus:'',
            pagination: {//分页相关模型数据
                currentPage: 1,//当前页码
                pageSize:10,//每页显示的记录数
                total:0,//总记录数
                queryString:null//查询条件
            },
            dataList: [],//当前页要展示的分页列表数据
        },
        //钩子函数，VUE对象初始化完成后自动执行
        created() {
            this.findPage();
        },
        methods: {
            //分页查询
            findPage() {
                //发送ajax请求，发送分页请求参数（每页条数，查询条件）
                var page ={
                    currentPage: this.pagination.currentPage,
                    pageSize: this.pagination.pageSize,
                    queryString: this.pagination.queryString
                };
                axios.post("/notices/findallbyuserid?tpname="+this.findstatus,page).then((res)=>{
                    //处理响应数据
                    this.pagination.total = res.data.total;
                    this.dataList = res.data.rows;
                })
            },
            //切换页码
            handleCurrentChange(currentPage) {
                //页面更改时，再次请求数据
                this.pagination.currentPage = currentPage;
                this.findPage();
            },
            quxiao(){
                this.$message.warning("已取消");
            },
            //已读
            rowclick(row, event, column){
                //ajax请求，设置为已读
                if(row.isread === 0){
                    //未读
                    axios.post("/notices/isread?noticesid=" + row.id).then((res)=>{
                        if(res.data.flag){
                            this.findPage();
                        }
                    })
                }else{

                }
            }
        }
    })
</script>
</html>